package com.example.musicdemo;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.LinearLayoutManager;
import android.Manifest;
import android.content.pm.PackageManager;
import android.os.Bundle;


import com.example.musicdemo.databinding.ActivityMainBinding;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ActivityMainBinding activityMainBind =DataBindingUtil.setContentView(this,R.layout.activity_main);
        activityMainBind.recycleView.setLayoutManager(new LinearLayoutManager(this));//设置布局管理器

        RecyclerViewAdapter adapter = new RecyclerViewAdapter(SongUtils.getAllSongs(getBaseContext()));//初始化一个适配器
        activityMainBind.recycleView.setAdapter(adapter);//设置适配器

        //检查权限
        if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED){

            ActivityCompat.requestPermissions(MainActivity.this,new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},1);
        }




    }

}